package com.auto.admin.service.impl;

import com.auto.admin.entity.ApiInfo;
import com.auto.admin.entity.bo.ApiInfoBO;
import com.auto.admin.mapper.ApiInfoMapper;
import com.auto.admin.service.ApiInfoService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.util.List;
import org.springframework.stereotype.Service;

/**
 * Description: ApiInfo映射 服务实现类
 * @author liangshf
 * @date 2019-04-30
 */
@Service
public class ApiInfoServiceImpl extends ServiceImpl<ApiInfoMapper, ApiInfo> implements
	ApiInfoService {

	@Override
	public List<ApiInfo> findByUrl(String url){
		QueryWrapper<ApiInfo> wrapper = new QueryWrapper<>();
		wrapper.likeLeft("url", url);
		wrapper.eq("del", 0);
		return baseMapper.selectList(wrapper);
	}

	@Override
	public List<ApiInfo> findByApplicationName(String applicationName){
		QueryWrapper<ApiInfo> wrapper = new QueryWrapper<>();
		wrapper.eq("application_name", applicationName);
		wrapper.eq("del", 0);
		return baseMapper.selectList(wrapper);
	}

	@Override
	public List<ApiInfo> findList(ApiInfoBO paramBO) {
		LambdaQueryWrapper<ApiInfo> queryWrapper = new LambdaQueryWrapper<>();
		if (paramBO.getApplicationName() != null) {
			queryWrapper.eq(ApiInfo::getApplicationName, paramBO.getApplicationName());
		}
		queryWrapper.eq(ApiInfo::getDel, 0);
		return baseMapper.selectList(queryWrapper);
	}
	
}
